package com.tzvtc.server.account.service;

import com.tzvtc.server.account.bean.PermissionBean;
import com.tzvtc.server.account.mapper.PermissionMapper;
import com.tzvtc.server.commons.security.SecurityLocal;
import jakarta.annotation.PostConstruct;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermissionService {

    private final PermissionMapper permissionMapper;


    public PermissionService(PermissionMapper permissionMapper) {
        this.permissionMapper = permissionMapper;
    }

    @PostConstruct
    public void list(){
        // 从数据库中查询出所有的权限
        List<PermissionBean> list = permissionMapper.select();
        // 将所有权限放入到功能空间中
        for (PermissionBean permissionBean : list) {
            SecurityLocal.permissionMap.put(permissionBean.getUri(),permissionBean);
        }
    }
}
